import {
  getPaymentList,
  getDetailPayment,
  getDeletePayment,
  submitPaymentInfo,
  getPaymentNoticeSumList,
  getPaymentNoticeList,
  getDeletePNSum,
  getDeletePNotice,
  submitPaymentNoticeSum,
  fetchPayClazz,
  fetchPayStatus,
} from "@/api/payment"
export default {
  namespaced: true, // 封闭
  state: {},
  mutations: {},
  getters: {},
  actions: {
    /**
     * 缴费管理
     */
    // 获取缴费管理列表
    async fetchPaymentData(context, payload) {
      let { businessId, searchName, payTypeId, startDate, endDate, perPage, page } = payload
      try {
        const { data } = await getPaymentList(businessId, searchName, payTypeId, startDate, endDate, perPage, page)
        return data
      } catch (err) {
        console.log(err)
      }
    },
    // 提交新增缴费管理列表
    async submitPaymentInfo(context, payload) {
      let {
        businessPayTheFeesMessageDetailId,
        payTheFeesTime,
        actionUserName,
        receiptMessage,
        receiptImage
       } = payload
      try {
        return await submitPaymentInfo(
          businessPayTheFeesMessageDetailId,
          payTheFeesTime,
          actionUserName,
          receiptMessage,
          receiptImage
        )
      } catch (err) {
        console.log(err)
      }
    },
    // 查看缴费列表详情
    async detailPayment(context, payload) {
      let { businessPayTheFeesId } = payload
      try {
        const { data } = await getDetailPayment(businessPayTheFeesId)
        return data
      } catch (err) {
        console.log(err)
      }
    },
    // 删除缴费列表
    async deletePayment(context, payload) {
      let { businessPayTheFeesId } = payload
      try {
        const { data } = await getDeletePayment(businessPayTheFeesId)
        return data
      } catch (err) {
        console.log(err)
      }
    },

    // 获取缴费通知汇总列表
    async fetchPaymentNoticeSumData(context, payload) {
      let { searchName, payTypeId, startDate, endDate, perPage, page } = payload
      try {
        const { data } = await getPaymentNoticeSumList(searchName, payTypeId, startDate, endDate, perPage, page)
        return data
      } catch (err) {
        console.log(err)
      }
    },
    // 提交新增缴费通知
    async fetchSubmitPaymentNoticeSum(context, payload) {
      let { content, startDate, endDate, marketAccountId, marketAccountName, payTypeId, sendType, businessDataList, sendRange , appointMoney} = payload
      try {
        // 后面记得改成活的
        const { data } = await submitPaymentNoticeSum(content, startDate, endDate, marketAccountId, marketAccountName, payTypeId, sendType, businessDataList, sendRange , appointMoney)
        return data
      } catch (err) {
        console.log(err)
      }
    },
    // 删除缴费通知汇总
    async fetchDeletePNSum(context, payload) {
      let { businessPayTheFeesMessageId } = payload
      try {
        const { data } = await getDeletePNSum(businessPayTheFeesMessageId)
        return data
      } catch (err) {
        console.log(err)
      }
    },

    // 获取缴费通知列表
    async fetchPaymentNoticeData(context, payload) {
      let { searchName, businessPayTheFeesMessageId, payStatus, payType, perPage, page } = payload
      try {
        const { data } = await getPaymentNoticeList(searchName, businessPayTheFeesMessageId, payStatus, payType, perPage, page)
        return data
      } catch (err) {
        console.log(err)
      }
    },
    // 删除缴费通知
    async fetchDeletePNotice(context, payload) {
      let { businessPayTheFeesMessageDetailId } = payload
      try {
        const { data } = await getDeletePNotice(businessPayTheFeesMessageDetailId)
        return data
      } catch (err) {
        console.log(err)
      }
    },

    async fetchPayClazz(context) {
      try {
        let responseData  = await fetchPayClazz()
        return responseData
      } catch (err){
        console.log(err)
      }
    },

    async fetchPayStatus(context) {
      try {
        let responseData = await fetchPayStatus()
        return responseData
      } catch(err) {
        console.log(err)
      }
    }
  }
}
